<?php

include_once '../tools/DbTools.php';

//开启SESSION功能
session_start();
$username = $_POST['uesrname'];
$password = $_POST['password'];
$newUrl = '';
$msg = '';
$is_valid = false;
if($username=='admin'&& $password=='123456'){
        $is_valid = true;
        $msg = '登入成功';
        $newUrl = 'adminInfo.php';
        session_start();
    $token = md5($username.$password.time());
    setcookie('Token',$token,time()+3600,'/');
    $_SESSION[$token] = [
        'uesrname'=> $username,
        'password' =>$password,
    ];


}
if(!$is_valid){
    $msg = '用户名或密码错误';
    $newUrl = 'adminloginUi.php';
}
?>


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<input type="hidden" id="newUrl" value="<?php echo $newUrl;?>">
<input type="hidden" id="msg" value="<?php echo $msg;?>">
</body>
<script>
    onload = function () {
        var newUrl = document.getElementById('newUrl').value;
        var msg = document.getElementById('msg').value;
        alert(msg);
        location.href = newUrl;
    }
</script>

</html>


